import request from '@/utils/request'

export function saveTestStructure(testStructure, testId) {
  const fd = new FormData()
  fd.set('testStructureId', testStructure.id? testStructure.id:-1)
  fd.set('title', testStructure.title)
  fd.set('score', testStructure.score)
  return request.post(`/test/${testId}/testStructure`, fd)
}

export function getTestStructure(testId) {
  return request.get(`/test/${testId}/testStructure`)
}

export function deleteTestStructure(textId, id) {
  return request.delete(`/test/${textId}/testStructure:${id}`)
}

export function testStructureSort(testId, id, sort) {
  const fd = new FormData()
  fd.set('sort', sort)
  return request.put(`/test/${testId}/testStructure:${id}/sort`, fd)
}
